<template>
  <!-- 待审提款订单 -->
  <div class="app-container">
    <div class="app-wrap">
      <search-table ref="table" :table-loading="listLoading" :table-data="dataList" @query="getDataList(true)" @reset="refresh">
        <template v-slot:row>
          <el-form-item label="渠道:" label-width="50px">
            <el-select v-model="listQuery.agent_id" placeholder="请选择渠道" filterable >
              <el-option label="全部" value="" ></el-option>
              <el-option :label="'【'+item.value+'】'+item.label" :value="item.value" v-for="(item, index) in channelData" :key="index"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item class="marginR20">
            <el-select v-model="listQuery.search_type" filterable placeholder="请选择类型">
              <el-option :label="item.label" :value="item.value" v-for="(item, index) in conditionData" :key="index"></el-option>
            </el-select>
            <el-input class="width200" type="number" v-model="listQuery.search_value" clearable placeholder="请输入数值"  />
          </el-form-item>
          <el-form-item  label="订单时间:" label-width="80px">
            <el-date-picker is-range v-model="listQuery.dateTime" type="datetimerange" range-separator="至" start-placeholder="开始日期" 
            end-placeholder="结束日期" class="full-width-input time-box" :default-time="['00:00:00', '23:59:59']" :clearable="false"></el-date-picker>
          </el-form-item>
          <el-form-item  label="订单来源:" label-width="80px">
            <el-select v-model="listQuery.withdraw_type" filterable placeholder="请选择类型">
              <el-option label="全部" :value="-1"></el-option>
              <el-option label="正常订单" :value="0"></el-option>
              <el-option label="拼多多提现" :value="1"></el-option>
            </el-select>
          </el-form-item>
        </template>
        <template v-slot:actions>
          <div class="statistic flexDetween" style="height:36px;">
            <div class="flex">
              <el-button type="info" size="mini" icon="el-icon-refresh" @click="getDataList">刷新</el-button> 
              <el-button :disabled="orderStatusDisable" v-permission="'withdrawalOrder.edit'" size="mini" type="primary" 
              @click.stop="editOrderStatus(1,checkedItem)">三方代付</el-button>

              <el-button :disabled="!checkedItem || !checkedItem.is_lock && !checkedItem.order_status" v-permission="'withdrawalOrder.edit'"  size="mini" type="primary" 
              @click.stop="editOrderStatus(2,checkedItem)">订单完成</el-button>

              <el-button :disabled="!checkedItem || !checkedItem.is_lock && !checkedItem.order_status" v-permission="'withdrawalOrder.edit'" size="mini" type="danger"
              @click.stop="editOrderStatus(3,checkedItem)">罚没</el-button>

              <el-button :disabled="!checkedItem || !checkedItem.is_lock && !checkedItem.order_status" v-permission="'withdrawalOrder.edit'" size="mini" type="warning" 
              @click.stop="editOrderStatus(4,checkedItem)">退回</el-button>

              <el-button v-permission="'withdrawalOrder.approval'" size="mini" type="danger" 
              @click.stop="isShowRiskDetails = true">风控警示设置</el-button>

              <el-button :type="formParams.is_auto_cash?'success':'info'" v-permission="'withdrawalOrder.approval'"  size="mini" icon="el-icon-s-check"
              @click.stop="approval">{{formParams.is_auto_cash?'关闭自动':'自动审批'}}</el-button>

              <el-button class="marginL20 marginR20" type="success" size="mini" icon="el-icon-wallet" @click="isShowTotalsDetails=!isShowTotalsDetails,getTotalOrderList()">统计</el-button>

              <div class="flex marginL20" v-show="isShowTotalsDetails"> 
                <p> 待审提款总额：<span class="colorGre">{{ totalForm.pending_money }}</span></p>
                <p> 待审提款笔数：<span class="colorGre">{{ totalForm.pending_count }}</span></p>
              </div>
            </div>
            <el-button type="primary" size="mini" icon="el-icon-download" :disabled="!dataList.length" @click="getExport">导出</el-button> 
          </div>
        </template>
        <template>
          <el-table-column align="center" type="index" width="50">
            <template slot-scope="scope">
              <el-radio v-model="scope.row.isChecked" :label="true" @change="handleCurrentChange(scope.row)">{{ '' }}</el-radio>
            </template>
          </el-table-column>
          <el-table-column prop="agent_id" label="渠道名" align="center" width="200" show-overflow-tooltip>
            <template slot-scope="scope">
              <span v-show="scope.row.agent_id">【{{scope.row.agent_id}}】{{ $public.channelLabel(scope.row.agent_id) }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="order_alert_status" label="警戒状况" align="center" width="90">
            <template slot-scope="scope">
              <el-button class="order_state" size="mini" :type="orderState(scope.row.order_alert_status)" circle>{{''}}</el-button> 
            </template>
          </el-table-column>
          <el-table-column prop="order_num" label="订单号" align="center" width="240">
            <template slot-scope="scope">
              <span class="item_details" @click.stop="handleCurrentChange(scope.row),isShowDetails = true">{{ scope.row.order_num }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="third_order_num" label="第三方订单号" align="center" width="220" />
          <el-table-column prop="withdraw_type" label="订单来源" align="center" width="120">
            <template slot-scope="scope">
              <el-tag :type="scope.row.withdraw_type?'danger':'waring'" >{{ scope.row.withdraw_type?'拼多多提现':'正常提现' }}</el-tag>
            </template>
          </el-table-column>
          <el-table-column prop="order_status" label="订单状态" align="center" width="100">
            <template slot-scope="scope">
              <el-tag :type="orderType(scope.row.order_status)" >{{ orderStatus(scope.row.order_status) }}</el-tag>
            </template>
          </el-table-column>
          <el-table-column prop="channel_id" label="提现渠道" align="center" width="150">
            <template slot-scope="scope">
              <span>{{ withdrawLabel(scope.row.channel_id) }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="is_lock" label="锁定状态" align="center" width="100">
            <template slot-scope="scope">
              <el-tag type="success" v-show="!scope.row.is_lock">未锁定</el-tag>
              <el-tag type="danger" v-show="scope.row.is_lock">锁定</el-tag>
            </template>
          </el-table-column>
          <el-table-column prop="user_id" label="用户ID" align="center" width="120">
            <template slot-scope="scope">
              <span class="item_details" @click="isShowUserDetails = true,checkedItem = scope.row">{{ scope.row.user_id }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="is_kol" label="是否是KOL" align="center" width="100">
            <template slot-scope="scope">
              <el-tag :type="scope.row.is_kol?'success':'info'" >{{ scope.row.is_kol?'KOL':'否' }}</el-tag>
            </template>
          </el-table-column>
          <el-table-column prop="account_type" label="账户类型" align="center" width="120">
            <template slot-scope="scope">
              <el-tag :type="accountTag(scope.row.account_type)">{{ accountType(scope.row.account_type)}}</el-tag>
            </template>
          </el-table-column>
          <el-table-column prop="recharge_reward" label="充值筹码" align="center" width="150" />
          <el-table-column prop="send_reward" label="赠送筹码" align="center" width="150" />
          <el-table-column prop="user_total_recharge" label="总充值" align="center" width="150" />
          <el-table-column prop="user_total_cash" label="总提款" align="center" width="150" />
          <el-table-column prop="user_total_water" label="总有效流水" align="center" width="150" />
          <el-table-column prop="user_total_game_income" label="总输赢" align="center" width="150">
            <template slot-scope="scope">
              <span :class="scope.row.user_total_game_income>0?'colorGre':'colorRed'">{{ scope.row.user_total_game_income }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="cash_money" label="提款金额" align="center" width="150" />
          <el-table-column prop="cash_sure_money" label="实际提款金额" align="center" width="150" />
          <el-table-column prop="created_at" label="创建时间" align="center" width="180" />
          <el-table-column prop="updated_at" label="修改时间" align="center" width="180" />
          <el-table-column prop="user_created_at" label="用户注册时间" align="center" width="180" />
          <el-table-column prop="admin_id" label="操作员" align="center" width="150" show-overflow-tooltip>
            <template slot-scope="scope">
              <span>{{ $public.accountLabel(scope.row.admin_id) }}<span v-show="scope.row.admin_id">【{{scope.row.admin_id}}】</span></span>
            </template>
          </el-table-column>
          <el-table-column align="left" fixed="right" prop="operation" label="操作" width="180">
            <template slot-scope="scope">
              <el-button v-permission="'withdrawalOrder.lock'" size="mini"  type="danger" 
                :disabled="scope.row.is_lock?true:false" @click.stop="orderChangeLock(scope.row)">锁定</el-button>
              <el-button v-permission="'withdrawalOrder.unlock'" size="mini" type="success" 
                :disabled="scope.row.is_lock?false:true" @click.stop="orderChangeLock(scope.row)">解锁</el-button>
            </template>
          </el-table-column>
        </template>
        <template v-slot:footer>
          <pagination  :total="currentTotal" :page.sync="listQuery.page" :limit.sync="listQuery.size" @pagination="getDataList" />
        </template>
      </search-table>
      <page-details :show="isShowDetails" :data="checkedItem" @onHideDetails="onHideDetails" />
    </div>
    <!-- 提现 -->
    <el-dialog :visible.sync="isShowReasonDetails" v-if="isShowReasonDetails" title="操作订单" width="45%" :before-close="handleClose" top="200px" :close-on-click-modal="false">
      <div v-if="orderStateType==1">
        <span class="box-title">提现渠道：</span>
        <el-select class="width240" v-model="channelID" placeholder="请选择提现渠道" filterable >
          <el-option v-show="item.status==1?true:false" :label="'【'+item.name+'】'" :value="item.pay_way_id" v-for="(item, index) in withdrawChannelData" :key="index"/>
        </el-select>
        <span class="marginL10">(用户【<span class="colorRed">{{checkedItem.user_id}}</span>】共有【<span class="colorRed">{{orderNum}}</span>】笔订单)</span>
      </div>
      <el-input v-else placeholder="请输入理由" type="textarea" :rows="3" v-model="reason" clearable></el-input>
      <span slot="footer" class="dialog-footer">
        <el-button size="medium" @click="handleClose">取 消</el-button>
        <el-button type="primary" size="medium" :loading="payShow" :disabled="payShow" @click="editReason">确 定</el-button>
      </span>
    </el-dialog>
    <!-- 风控警示 -->
    <el-dialog :visible.sync="isShowRiskDetails" v-if="isShowRiskDetails" title="风控警示设置" width="45%" :before-close="handleClose" top="200px" :close-on-click-modal="false">
      <el-form ref="riskForm" :model="formParams" :rules="ruleForm" label-position="right" label-width="0">
        <form-item title="超过今日充值倍数示警" :pass="true" value="more_pay_notice">
          <el-input-number :min="0" :precision="0" v-model="formParams.more_pay_notice" controls-position="right" clearable placeholder="请输入超过今日充值倍数示警"/>
        </form-item>
      </el-form>
      <div>
        <p>限制条件为：</p>
        <p class="colorRed" style="font-weight: 500;">红：今日输赢 ≥ 今日充值*{{formParams.more_pay_notice}}  或 今日提现(+此笔订单) ≥ 今日充值*{{formParams.more_pay_notice}}</p>
        <div class="colorYe" style="font-weight: 500;">
          黄：今日充值 {{'<'}} 今日提现(+此笔订单) 或 今日下注 {{'<'}} 今日提现(+此笔订单)
          <p>今日输赢 {{'<'}} 今日充值*{{formParams.more_pay_notice}}  或 今日提现(+此笔订单) {{'<'}} 今日充值*{{formParams.more_pay_notice}}</p>
        </div>
        <p class="colorGre" style="font-weight: 500;">绿：今日充值 ≥ 今日提现(+此笔订单) 且 今日下注 ≥ 今日提现(+此笔订单) </p>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button size="medium" @click="handleClose">取 消</el-button>
        <el-button type="primary" size="medium" @click="changeRisk('riskForm')">确 定</el-button>
      </span>
    </el-dialog>
    <GoogleCheck ref="GoogleCheck" :show="googleCheckShow" :type="2" @handleConfirm="editReason" @handleClose="handleQrClose"/>
    <user-details :show="isShowUserDetails" :data="checkedItem" @onHideDetails="onHideDetails" />
  </div>
</template>

<script>
import { throttle } from '@/utils/index'
import {
  getWithdrawalOrder,
  editWithdrawalOrder,
  lockWithdrawalOrder,
  unlockWithdrawalOrder,
  withdrawalOrderChannels,
  exportWithdrawalOrder,
  orderRisk,
  orderSummation,
  getOrderRisk
} from '@/api/order'
import { 
  ORDER_PAY,
  ORDER_STATUS,
  ORDER_STATE,
  ACCOUNT_TYPE,
 } from '@/utils/enum'
import PageDetails from './page-details.vue'
import SearchTable from '@/components/SearchTable'
import GoogleCheck from '@/components/GoogleCheck'
import UserDetails from '@/views/userManage/user/page-details.vue'
export default {
  name: 'arraignment',
  components: {
    PageDetails,
    SearchTable,
    GoogleCheck,
    UserDetails
  },
  data () {
    return {
      ORDER_PAY,
      ORDER_STATUS,
      ORDER_STATE,
      ACCOUNT_TYPE,
      channelData: this.$store.state.commonState.channelDataArray,
      conditionData:[
        { label:'用户ID',value:1 },
        { label:'订单号',value:2 },
        { label:'第三方订单号',value:3 },
        { label:'≥大于等于的金额',value:4 },
        { label:'≤小于等于的金额',value:5}
      ],
      totalForm:{
        pending_count: '', //待审订单笔数
        pending_money: '', //待审订单总额
      },
      payShow:false,
      isShowDetails: false,
      isShowReasonDetails: false,
      isShowRiskDetails: false,
      googleCheckShow: false,
      isShowUserDetails: false,
      isShowTotalsDetails: false,
      reason:'',
      checkedItem: null,
      listLoading: true,
      orderStateType: 1,
      withdrawChannelData: [],
      channelID: '',
      dataList: [],
      listQuery: {
        page: 1,
        size: 50,
        search_type: 1,
        search_value:'',
        order_status:'0,1',
        withdraw_type: -1,
        agent_id:'',
        dateTime: [this.$public.getDateWeek('s',0)+' 00:00:00',this.$public.getDateWeek('e',0)+' 23:59:59'],
        start_time: '',
        end_time: '',
      },
      currentTotal: 0,
      formParams: {
        id:0,
        is_auto_cash:0,
        more_pay_notice: '', //超过今日充值倍数示警
      },
      ruleForm:{
        more_pay_notice: [{ required: true, trigger: 'blur', message: '请输入超过今日充值倍数示警', }],
      },
      orderNum:0
    }
  },
  computed:{
    orderStatusDisable(){
      let checkedItem=this.checkedItem
      if(!checkedItem){
        return true
      }else if(checkedItem && checkedItem.is_lock && checkedItem.order_status!=1){
        return false
      }else{
        return true
      }
    }
  },
  created () {},
  activated(){
    this.channelData=this.$store.state.commonState.channelDataArray
    this.getWithdrawalChannelList()
    this.getRiskInfo()
  },
  methods: {
    // 提现订单渠道
    getWithdrawalChannelList () {
      let that = this;
      withdrawalOrderChannels().then(res => {
        if (res.code == 1) {
          res.data.forEach(item => {
            item.success_rate = item.success_rate/100
          })
          that.withdrawChannelData=res.data
        }
        that.getDataList();
      }).catch((error) => {
        that.$message.error(error.msg)
      })
    },
    // 待审核订单
    async getDataList (query) {
      let that = this,params=JSON.parse(JSON.stringify(that.listQuery));
      if(query && !query.page){
        params.page=1
        params.size=50
      }
      that.dataList = [];
      that.checkedItem = null;
      if (params.dateTime && params.dateTime[0] && params.dateTime[1]) {
        params.start_time = that.$public.standardDate(params.dateTime[0])
        params.end_time = that.$public.standardDate(params.dateTime[1])
      }else{
        params.start_time = ''
        params.end_time = ''
      }
      if(params.search_type==4 || params.search_type==5){
        params.search_value=that.$public.mathNumberMultiply(params.search_value,10000)
      }
      const response = await getWithdrawalOrder(params)
      if (response.code == 1) {
        if(response.data.list){
          response.data.list.forEach((item,index) => {
            item.isChecked = false
            item.recharge_reward=that.$public.mathNumberDivideWan(item.recharge_reward)
            item.send_reward=that.$public.mathNumberDivideWan(item.send_reward)
            item.cash_money=that.$public.mathNumberDivideWan(item.cash_money)
            item.cash_sure_money=that.$public.mathNumberDivideWan(item.cash_sure_money)
            item.user_total_recharge=that.$public.mathNumberDivideWan(item.user_total_recharge)
            item.user_total_cash=that.$public.mathNumberDivideWan(item.user_total_cash)
            item.user_total_water=that.$public.mathNumberDivideWan(item.user_total_water)
            item.user_total_game_income=that.$public.mathNumberDivideWan(item.user_total_game_income)
          })
          that.dataList = response.data.list
          that.currentTotal = response.data.total
        }
      }else{
        that.$message.error(response.msg)
      }
      that.listLoading = false
    },
    // 订单合计
    getTotalOrderList() {
      let that = this,params=JSON.parse(JSON.stringify(that.listQuery));
      if(!that.isShowTotalsDetails) return
      if (params.dateTime && params.dateTime[0] && params.dateTime[1]) {
        params.start_time = that.$public.standardDate(params.dateTime[0])
        params.end_time = that.$public.standardDate(params.dateTime[1])
      }else{
        params.start_time = ''
        params.end_time = ''
      }
      if(params.search_type==4 || params.search_type==5){
        params.search_value=that.$public.mathNumberMultiply(params.search_value,10000)
      }
      orderSummation(params).then(res => {
        if (res.code == 1) {
          res.data.pending_money=that.$public.mathNumberDivideWan(res.data.pending_money)
          that.totalForm=res.data
        }
      }).catch((error) => {
        that.$message.error(error.msg)
      })
    },
    // 获取风控信息
    getRiskInfo(){
      let that = this;
      getOrderRisk({}).then(res => {
        if (res.code == 1) {
          that.formParams=res.data
        }
      }).catch((error) => {
        that.$message.error(error.msg)
      })
    },
    // 修改风控
    changeRisk(formvalue){
      let that = this,params = JSON.parse(JSON.stringify(that.formParams));
      that.$refs[formvalue].validate((valid) => {
        if (valid) {
          orderRisk(params).then(res => {
            if (res.code == 1) {
              that.$message.success(res.msg)
              that.onHideDetails(true)
            }
          }).catch((error) => {
            that.$message.error(error.msg)
          })
        } else {
          return false;
        }
      })
    },
    // 自动审批
    approval(){
      let that = this,params = JSON.parse(JSON.stringify(that.formParams)),content='是否开启自动审批?<span class="colorRed">（风控绿灯会自动放行）</span>';
      if(params.is_auto_cash){
        content='是否关闭自动审批?'
        params.is_auto_cash=0
      }else{
        params.is_auto_cash=1
      }
      that.$alert(content, '警告', {
        showCancelButton: true,
        dangerouslyUseHTMLString: true,
        confirmButtonText: '确定',
        cancelButtonText: '取消',
      }).then(() => {
        orderRisk(params).then(res => {
          if (res.code == 1) {
            that.getRiskInfo()
            that.onHideDetails(true)
            that.$message.success(res.msg)
          }
        }).catch((error) => {
          that.$message.error(error.msg)
        })
      }).catch(() => { });
    },
    // 修改订单状态 1是代付中 2是订单完成 3是罚没 4是退回
    async editOrderStatus(type,row){
      let that = this,params={
        page: 1,
        size: 50,
        search_type: 1,
        search_value:row.user_id,
        order_status:'0,1',
        withdraw_type: -1,
        agent_id:'',
        start_time: '',
        end_time: '',
      },content='';
      that.orderStateType=type
      that.handleCurrentChange(row)
        const response = await getWithdrawalOrder(params)
        if (response.code == 1) {
          if(response.data){
            that.orderNum = response.data.total
          }
          switch (type) {
            case 1:
              that.isShowReasonDetails=true
            break;
            case 2:
              content=`是否确认用户【<span class="colorRed">${row.user_id}</span>】的【<span class="colorRed">${row.order_num}</span>】订单完成,该用户共有【<span class="colorRed">${that.orderNum}</span>】笔订单`
            break;
            case 3:
              content=`是否罚没用户【<span class="colorRed">${row.user_id}</span>】的【<span class="colorRed">${row.order_num}</span>】订单完成,该用户共有【<span class="colorRed">${that.orderNum}</span>】笔订单`
            break;
            case 4:
              content=`是否退回用户【<span class="colorRed">${row.user_id}</span>】的【<span class="colorRed">${row.order_num}</span>】订单完成,该用户共有【<span class="colorRed">${that.orderNum}</span>】笔订单`
            break;
          }
          if(type!=1){
            that.$alert(content, '警告', {
              dangerouslyUseHTMLString: true,
              showCancelButton: true,
              confirmButtonText: '确定',
              cancelButtonText: '取消',
            }).then(() => {
              that.isShowReasonDetails=true
            }).catch(() => { });
          }
        }else{
          that.$message.error(response.msg)
        }
    },
    editReason:throttle(function () {
      let that = this,name='';
      if(that.orderStateType !=1 && !that.reason){
        return that.$message.error('请输入理由')
      }
      if(that.channelID){
        name=this.withdrawChannelData.find((item) => item.pay_way_id === that.channelID).name
      }
      // 第三方代付
      if(that.orderStateType==1){
        that.payShow=true
      }else{
        that.payShow=false
      }
      // 订单完成或者订单代付校验
      if(that.orderStateType==1 || that.orderStateType==2){
        // 谷歌验证码
        if(!that.$refs.GoogleCheck.formParams.google_code){
          return that.googleCheckShow=true
        }else{
          that.googleCheckShow=false
        }
      }
      editWithdrawalOrder({
        order_num: that.checkedItem.order_num, //订单号
        reason: that.reason, //变更理由
        order_status: that.orderStateType,
        channel_id:that.channelID?that.channelID:0,
        channel_name:name
      }).then(res => {
        if (res.code == 1) {
          that.payShow=false
          that.$message.success(res.msg)
          that.getDataList()
          that.handleClose()
        }
      }).catch((error) => {
        that.payShow=false
        that.$message.error(error.msg)
      })
    }, 3000),
    // 获取当前用户订单数
    async getOrderNum(row){
      let that = this,params={
        page: 1,
        size: 50,
        search_type: 1,
        search_value:row.user_id,
        order_status:'0,1',
        agent_id:'',
        withdraw_type: -1,
        start_time: '',
        end_time: '',
      },num=0,content='';
      const response = await getWithdrawalOrder(params)
      if (response.code == 1) {
        if(response.data){
          num = response.data.total
        }
        content=`是否确认用户【${row.user_id}】的【${row.order_num}】订单完成,该用户共有【${num}】笔订单`
        that.$confirm(content, '警告', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
        }).then(() => {
          that.isShowReasonDetails=true
        }).catch(() => { });
      }else{
        that.$message.error(response.msg)
      }
    },
    // 锁定
    orderChangeLock(row){
      let that = this,title='';
      that.handleCurrentChange(row)
      if(row.is_lock){
        title=`是否解锁【${row.order_num}】订单`
      }else{
        title=`是否锁定【${row.order_num}】订单`
      }
      that.$confirm(title, '警告', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
      }).then(() => {
        if(row.is_lock){
          unlockWithdrawalOrder({
            order_num: row.order_num, //订单号
          }).then(res => {
            if (res.code == 1) {
              that.$message.success('解锁成功')
              that.getDataList()
            }
          }).catch((error) => {
            that.$message.error(error.msg)
          })
        }else{
          lockWithdrawalOrder({
            order_num: row.order_num, //订单号
          }).then(res => {
            if (res.code == 1) {
              that.$message.success('锁定成功')
              that.getDataList()
            }
          }).catch((error) => {
            that.$message.error(error.msg)
          })
        }
      }).catch(() => { });
    },
    // 导出
    getExport(){
      let that = this,serveUrl=process.env.VUE_APP_BASE_API.substring(0,process.env.VUE_APP_BASE_API.length-6);
      exportWithdrawalOrder(that.listQuery).then(res => {
        if (res.code == 1) {
          window.open(serveUrl+res.data)
        }
      }).catch((error) => {
        that.$message.error(error.msg)
      })
    },
    // 订单展示
    orderStatus(cellValue){
      return (this.ORDER_STATUS.find((item) => item.value === cellValue)?.label || "-");
    },
    // 订单状态
    orderType(cellValue){
      return (this.ORDER_STATUS.find((item) => item.value === cellValue)?.type || "-");
    },
    // 支付方式
    payType(cellValue){
      if(cellValue){
        return (this.ORDER_PAY.find((item) => item.value === cellValue)?.label || "-");
      }
    },
    // 订单警戒状态
    orderState(cellValue){
      return (this.ORDER_STATE.find((item) => item.value === cellValue)?.label || "-");
    },
    // 账号类型展示
    accountType(cellValue){
      return (this.ACCOUNT_TYPE.find((item) => item.value === cellValue)?.label || "测试账号");
    },
    // 账号类型展示
    accountTag(cellValue){
      return (this.ACCOUNT_TYPE.find((item) => item.value === cellValue)?.type || "-");
    },
    // 提现渠道
    withdrawLabel(cellValue){
      return (this.withdrawChannelData.find((item) => item.pay_way_id === cellValue)?.name || "-");
    },
    // 选择表格数据
    handleCurrentChange (val) {
      this.checkedItem = val
      this.dataList.map(item => {
        if (item.id === val.id) {
          item.isChecked = true
        } else {
          item.isChecked = false
        }
      })
    },
    // 取消谷歌验证
    handleQrClose(){
      this.googleCheckShow = false
      this.payShow = false
    },
    // 关闭
    handleClose(){
      this.isShowDetails=false
      this.isShowReasonDetails=false
      this.googleCheckShow=false
      this.isShowUserDetails=false
      this.isShowRiskDetails=false
      this.payShow=false
      this.reason=''
    },
    // 刷新
    refresh:throttle(function () {
      let that = this;
      that.listQuery = {
        page: 1,
        size: 50,
        search_type: 1,
        search_value:'',
        withdraw_type: -1,
        order_status:'0,1',
        agent_id:'',
        dateTime: [this.$public.getDateWeek('s',0)+' 00:00:00',this.$public.getDateWeek('e',0)+' 23:59:59'],
        start_time: '',
        end_time: '',
      }
      that.totalForm={
        pending_count: '', 
        pending_money: '', 
      }
      that.getDataList();
    }, 2000),
    onHideDetails (show) {
      this.isShowDetails = false
      this.isShowReasonDetails=false
      this.googleCheckShow=false
      this.isShowUserDetails=false
      this.isShowRiskDetails=false
      if (show) {
        this.getDataList()
      }
    },
  }
}
</script>

<style lang="scss" scoped>
.order_state {
  width: 27px;
  height: 27px;
}
</style>
